package cn.lingyangwl.agile.system.model.rqrs.diy;

import cn.lingyangwl.framework.tool.core.tree.TreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 移动端菜单
 *
 * @author shenguangyang
 */
@Getter
@Setter
@ApiModel(value = "移动端菜单")
public class DiyAppLinkResp extends DiyAppLinkBase implements TreeNode<Long, DiyAppLinkResp>, Serializable {
    private Long id;

    @ApiModelProperty(value = "创建者")
    private String createdBy;

    @ApiModelProperty(value = "创建时间")
    private Date createdAt;

    @ApiModelProperty(value = "更新者")
    private String updatedBy;

    @ApiModelProperty(value = "更新时间")
    private Date updatedAt;

    @ApiModelProperty(value = "标题, 前端需要")
    protected String slotTitle;

    /**
     * 子节点
     */
    protected List<DiyAppLinkResp> children;

    @ApiModelProperty(value = "是否为叶子节点")
    private Boolean isLeaf = false;

    public String getKey() {
        return String.valueOf(this.id);
    }

    public String getTitle() {
        return this.getName();
    }

    @Override
    public Long treeId() {
        return this.id;
    }

    @Override
    public void treeId(Long id) {
        this.id = id;
    }

    @Override
    public Long treeParentId() {
        return super.getParentId();
    }

    @Override
    public void treeParentId(Long parentId) {
        super.setParentId(parentId);
    }

    @Override
    public List<DiyAppLinkResp> children() {
        return this.children;
    }

    @Override
    public String name() {
        return this.getName();
    }

    @Override
    public void children(List<DiyAppLinkResp> children) {
        this.children = children;
    }

    @Override
    public void treeLeaf(Boolean treeLeaf) {
        this.isLeaf = treeLeaf;
    }

    @Override
    public void setName(String name) {
        super.setName(name);
        this.slotTitle = name;
    }
}
